class StudentVO {
    private name: string;
    private rollNo: number;
    constructor(name: string, rollNo: number) {
        this.name = name;
        this.rollNo = rollNo;
    }
    public getName(): string {
        return this.name;
    }
    public setName(name: string): void {
        this.name = name;
    }
    public getRollNo(): number {
        return this.rollNo;
    }
    public setRollNo(rollNo: number): void {
        this.rollNo = rollNo;
    }
}

class StudentBO {
    students: StudentVO[];
    public constructor() {
        this.students = [];
        const student1: StudentVO = new StudentVO("John", 1);
        const student2: StudentVO = new StudentVO("Jane", 2);
        this.students.push(student1);
        this.students.push(student2);
    }
    public deleteStudent(student: StudentVO): void {
        const index: number = this.students.indexOf(student);
        if (index !== -1) {
            console.log(`Student: Roll No ${student.getRollNo()} deleted.`);
            this.students.splice(index, 1);
        }
    }
    public getAllStudents(): StudentVO[] {
        return this.students;
    }
    public getStudent(rollNo: number): StudentVO | null {
        return this.students.find(student => student.getRollNo() === rollNo) || null;
    }
    public updateStudent(student: StudentVO): void {
        const studentToUpdate: StudentVO | null = this.getStudent(student.getRollNo());
        if (studentToUpdate !== null) {
            studentToUpdate.setName(student.getName());
            console.log(`Student: Roll No ${student.getRollNo()} updated.`);
        }
    }
}

function main() {
    const studentBO: StudentBO = new StudentBO();
    studentBO.getAllStudents().forEach(student => console.log(`Student: Name ${student.getName()}, Roll No ${student.getRollNo()}`));
    const student: StudentVO = studentBO.getStudent(1) as StudentVO;
    student.setName('Mike');
    studentBO.updateStudent(student);
    console.log(`Student: Name ${student.getName()} Roll No ${student.getRollNo()} updated.`);
}

main();
